<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/13
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/ajaxfileupload.js" charset="utf-8"></script>
    <style>
        .fileinput-button {
            position: relative;
            display: inline-block;
            overflow: hidden;
        }

        .fileinput-button input {
            position: absolute;
            right: 0px;
            top: 0px;
            opacity: 0;
            -ms-filter: 'alpha(opacity=0)';
            font-size: 200px;
        }
    </style>

    <script>
        //上传规格对应图片
        function ajaxUploads(obj) {
            $.ajaxFileUpload({
                //处理文件上传操作的服务器端地址(可以传参数,已亲测可用)
                url: "fileUploadt.html",
                secureuri: false,
                fileElementId: "fileUpload",
                //是否启用安全提交,默认为false
                dataType: 'text',
                success: function (data, status) {
                    data = jQuery.parseJSON(data)


                    //服务器响应成功时的处理函数
                    if (data.error == 0) {
                        var filesStr = "<br><a href='" + data.url + "'>" + data.fileName + "</a>";

                        alert
                        $("#urls").val($("#urls").val()+"!,"+data.url);
                        $("#fileNames").val($("#fileNames").val()+"!,"+data.fileName);
                        $("#fileDiv").append(filesStr);
                    }
                    else {
                        layer.msg(data.message);
                    }
                },
                error: function (data, status, e) { //服务器响应失败时的处理函数
                    layer.msg(data.message);
                }
            })
        };
    </script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <form class="form-horizontal" id="demandForm" name="demandForm">
        <input type="hidden" id="bugId" name="bugId" value="${tBugSource.id}">
        <input type="hidden" id="status" name="status" value="${tBugSource.status}">
        <div class="tabs-container">
            <fieldset>
                <div class="form-group">
                    <label class="col-sm-2 control-label">处理意见：</label>
                    <div class="col-sm-7">
                                    <textarea id="remark" name="remark"
                                              class="form-control"
                                              rows="5"></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <div class="col-sm-9">
                                <div id="fileDiv" align="left">
                                        <span class="btn btn-success fileinput-button" style="text-align: right">
                                            <span>文件上传</span>
                                            <input id="fileUpload" name="fileUpload" type="file"
                                                   onChange="ajaxUploads(this)">
                                            <input type='hidden' id="fileNames" name='fileNames'>
                                            <input type='hidden' id="urls" name='urls'>
                                        </span>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>
            <fieldset>
                <div class="form-group">
                    <div class="col-sm-7" style="text-align: center;">

                        <input value="提交" class="btn  btn-primary" type="button" id="submitBtn">
                        <button id="closeBut" onclick="closeWin()" class="btn  btn--white" type="button">关闭</button>
                    </div>
                </div>
            </fieldset>
        </div>
    </form>
</div>


<script>
    function closeWin() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }


    $("#submitBtn").click(function () {
        var remark = $("#remark").val();
        var bugId = $("#bugId").val();
        var status = $("#status").val();
        var urls = $("#urls").val();
        var fileNames = $("#fileNames").val();


        var args = {
            "bugId": bugId,
            "status": status,
            "remark":remark,
            "urls": urls,
            "fileNames": fileNames
        }

        var url = "disposeBug.html";
        //加载进度条
        layer.load(2, {
            shade: [0.2, '#999999'] //0.1透明度的白色背景
        });
        $.post(url, args, function (data) {
            data = jQuery.parseJSON(data);
            //保存成功
            if (data.code == 1) {
                layer.closeAll('loading');
                layer.alert(data.msg,
                    function () {
                        parent.location.reload();
                    });


            } else {
                //失败
                layer.alert("失败");
                layer.closeAll('loading');
            }
        });

    });

</script>
</body>
</html>
